import random as r


class Tortoise:
    step = 2
    axis = [0, 0]
    area = [0, 0]

    def __init__(self, a, b):
        self.area[0] = a
        self.area[1] = b

    def start_axis(self, x=0, y=0):
        self.axis[0] = x
        self.axis[1] = y
        return self.axis

    def move(self):
        while True:
            temp_x = r.randint(-self.step, self.step)
            temp_y = r.randint(-self.step, self.step)
            if temp_x == 0 and temp_y == 0:
                continue
            self.axis[0] = self.axis[0] + temp_x
            self.axis[1] = self.axis[1] + temp_y
            for i in range(0, 2):
                if self.axis[i] < 0:
                    self.axis[i] = 0 - self.axis[i]
                if self.axis[i] > 10:
                    self.axis[i] = 20 - self.axis[i]
            return self.axis


class Fish:
    step = 1
    area = [0, 0]
    axis = [0, 0]

    def __init__(self, a, b):
        self.area[0] = a
        self.area[1] = b

    def start_axis(self):
        self.axis[0] = r.randint(self.area[0], self.area[1])
        self.axis[1] = r.randint(self.area[0], self.area[1])
        return self.axis

    def move(self, axis):
        self.axis = axis
        while True:
            temp_x = r.randint(-self.step, self.step)
            temp_y = r.randint(-self.step, self.step)
            if temp_x == 0 and temp_y == 0:
                continue
            self.axis[0] = self.axis[0] + temp_x
            self.axis[1] = self.axis[1] + temp_y
            for i in range(0, 2):
                if self.axis[i] < 0:
                    self.axis[i] = 0 - self.axis[i]
                if self.axis[i] > 10:
                    self.axis[i] = 20 - self.axis[i]
            return self.axis


energy = 100
tort = Tortoise(1, 10)
tort_axis = tort.start_axis(1, 1)
print('-----------------------------')
print('乌龟的位置是：', tort_axis)
print('乌龟的体力：%d' % energy)
fish = Fish(1, 10)
fish_axis = {}
flag = 1
while True:
    temp_axis = fish.start_axis()
    if flag == 1 and temp_axis != tort_axis:
        fish_axis.setdefault(flag, 0)
        fish_axis[flag] = temp_axis.copy()
        print('Fish%d的位置是：' % flag, fish_axis[flag])
        flag += 1
    if flag > 1 and temp_axis != fish_axis[flag - 1] and temp_axis != tort_axis:
        fish_axis.setdefault(flag, 0)
        fish_axis[flag] = temp_axis.copy()
        print('Fish%d的位置是：' % flag, fish_axis[flag])
        flag += 1
    if flag > 10:
        break
print('----------游戏开始-----------')

while True:
    num = list(fish_axis.keys())
    length = len(num)
    for i in range(0, length):
        while True:
            temp_axis = fish.move(fish_axis[num[i]])
            if i == 0:
                fish_axis[num[i]] = temp_axis.copy()
                print('fish%d的位置是：' % num[i], fish_axis[num[i]])
                flag = 1
            elif temp_axis != fish_axis[num[i - 1]]:

                fish_axis[num[i]] = temp_axis.copy()
                print('fish%d的位置是：' % num[i], fish_axis[num[i]])
                flag = 1
            if flag == 1:
                break
    tort_axis = tort.move()
    print('乌龟的位置是：', tort_axis)
    energy -= 1

    for i in num:
        if fish_axis[i] == tort_axis:
            print('fish%s被吃掉' % i)
            fish_axis.pop(i)
            print('乌龟回复20点体力')
            energy += 20
    print('乌龟的体力：%d' % energy)

    print('-----------------------------')
    if fish_axis == {}:
        print('乌龟获胜')
        break
    elif energy == 0:
        print('小鱼获胜')
        break
